package com.leoman.spinningmachine.tab3;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.leoman.helper.util.FrescoUtil;
import com.leoman.spinningmachine.R;
import com.leoman.spinningmachine.constant.Constant;
import com.leoman.spinningmachine.grouprecyclerview.GroupRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018-05-07.
 */
public class LeaveAdapter extends GroupRecyclerAdapter<String,LeaveGroupHolder,LeaveContentHolder> {
    private Context mContext;
    private List<String> mList = new ArrayList<>();

    private LayoutInflater inflater;
    public LeaveAdapter(Context context,List<String> groups) {
        super(groups);
        mContext = context;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    protected LeaveGroupHolder onCreateGroupViewHolder(ViewGroup parent) {
        return new LeaveGroupHolder(inflater.inflate(R.layout.item_leave_head,null));
    }

    @Override
    protected LeaveContentHolder onCreateChildViewHolder(ViewGroup parent) {
        return new LeaveContentHolder(inflater.inflate(R.layout.item_leave,null));
    }

    @Override
    protected void onBindGroupViewHolder(LeaveGroupHolder holder, int groupPosition) {
        holder.tv_month.setText("本月");
        holder.tv_count.setText("(3)");
    }

    @Override
    protected void onBindChildViewHolder(LeaveContentHolder holder, int groupPosition, int childPosition) {
        FrescoUtil.setImg(mContext,holder.iv_pic, Constant.pics[3]);
        if(childPosition == 2){
            holder.view.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    protected int getChildCount(String group) {
        return 3;
    }
}
